<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');

include "dbconn.php";

$page  = $_GET["page"];
$limit  = $_GET["limit"];

if(empty($page)) {
	$page = 1;
}
if(empty($limit)) {
	$limit = 20;
}
$start = ($page-1) * $limit;

$qry = "select * from cartoon order by utime desc limit $start , $limit";
$res = mysql_query($qry, $db);
while($row = mysql_fetch_array($res)) {
	$rows[] = $row;
}
if(sizeof($rows) > 0) {
	$data = array(
				"result" => "success",
				"count" => sizeof($rows),
				"items" => $rows
			);
	
} else {
	$data = array(
				"result" => "fail"
			);
}

echo json_encode($data);

mysql_close($db);
?>